package com.iflytek.astron.console.toolkit.common;

import lombok.Getter;
import lombok.ToString;

/**
 * @program: AICloud-Customer-Service-Robot
 * @description: Unified return status enum codes
 * @author: xywang73
 * @create: 2020-10-23 14:25
 */
@Getter
@ToString
public enum CustomExceptionCode {
    // Knowledge base error codes
    REPO_NAME_DUPLICATE(10001, "Duplicate knowledge base exists"),
    REPO_TYPE_NOT_MATCH(10002, "Knowledge base does not match the type"),
    REPO_NOT_EXIST(10003, "Knowledge base does not exist"),
    REPO_SUBSCRIPTION_FAILED(10004, "Knowledge base subscription failed"),
    REPO_STATUS_ILLEGAL(10005, "Knowledge base status is illegal"),
    REPO_FILE_UPLOAD_FAILED_PIC_5MB(10006, "Upload failed, image size cannot exceed 5MB"),
    REPO_FILE_UPLOAD_FAILED_FILE_20MB(10007, "Upload failed, file size cannot exceed 20MB"),
    REPO_FILE_UPLOAD_FAILED_WORDS_100W(10008, "Upload failed, file character count must be less than 1 million"),
    REPO_FILE_TYPE_EMPTY_XINGCHEN(10009, "Xingchen file type is empty"),
    REPO_FILE_UPLOAD_FAILED_FILE_10MB_XINGCHEN(100010, "Upload failed, Xingchen file size of this type cannot exceed 10MB"),
    REPO_FILE_UPLOAD_FAILED_FILE_100MB_XINGCHEN(10011, "Upload failed, Xingchen file size of this type cannot exceed 100MB"),
    REPO_FILE_UPLOAD_FAILED(10012, "Upload failed"),
    REPO_FILE_SLICE_FAILED(10013, "Slicing failed"),
    REPO_FILE_SLICE_RANGE_16_124(10014, "Slice length range [16, 1024]"),
    REPO_FILE_ALL_CLEAN_FAILED(10015, "All file cleaning failed"),
    REPO_FILE_GET_KNOWLEDGE_FAILED(10016, "Failed to get knowledge points"),
    REPO_FILE_EMBEDDING_FAILED(10017, "Embedding failed"),
    REPO_FILE_SIZE_LIMITED(10018, "File limit exceeded, please delete other files or subscribe to membership to try again!"),
    REPO_FILE_NAME_CANNOT_EMPTY(10019, "File name cannot be empty"),
    REPO_FOLDER_NAME_ILLEGAL(10020, "Does not comply with folder naming rules"),
    REPO_FILE_NOT_EXIST(10021, "File does not exist"),
    REPO_FILE_DELETE_FAILED(10022, "Delete failed"),
    REPO_FOLDER_NOT_EXIST(10023, "Folder does not exist"),
    REPO_FILE_DOWNLOAD_FAILED(10024, "File download failed"),
    REPO_KNOWLEDGE_NOT_EXIST(10025, "Knowledge block does not exist"),
    REPO_KNOWLEDGE_GET_FAILED(10026, "Failed to get knowledge points"),
    REPO_KNOWLEDGE_ALL_EMBEDDING_FAILED(10027, "All knowledge points embedding failed"),
    REPO_KNOWLEDGE_NO_TASK(10028, "No corresponding task found"),
    REPO_KNOWLEDGE_DOWNLOAD_FAILED(10029, "Download & parse file error"),
    REPO_KNOWLEDGE_ADD_FAILED(10030, "Failed to add knowledge point"),
    REPO_KNOWLEDGE_MODIFY_FAILED(10031, "Failed to modify knowledge point"),
    REPO_KNOWLEDGE_DELETE_FAILED(10032, "Failed to delete knowledge block"),
    REPO_KNOWLEDGE_TAG_TOO_LONG(10033, "Tag is too long, please keep it within 30 characters"),
    REPO_KNOWLEDGE_SPLITTING(10034, "Generating slice preview, please wait"),
    REPO_SOME_IDS_MUST_INPUT(10035, "(repoId and parentId) or datasetId must be provided"),
    REPO_NOT_FOUND(10036, "Repo not found"),
    REPO_FILE_DISABLED(10037, "Document is disabled"),
    REPO_KNOWLEDGE_QUERY_FOUND(10038, "Knowledge retrieval failed"),
    REPO_DELETE_FAILED_BOT_USED(10039, "Knowledge base has associated bot usage and cannot be deleted"),
    REPO_FILE_UPLOAD_TYPE_NOT_EXIST(10040, "Upload failed: file type not supported"),

    // Workflow error codes
    WORKFLOW_VERSION_ADD_FAILED(20001, "Workflow version addition failed"),
    WORKFLOW_VERSION_GET_NAME_FAILED(20002, "Failed to get workflow version name"),
    WORKFLOW_VERSION_REDUCTION_FAILED(20003, "Workflow version restoration failed"),
    WORKFLOW_VERSION_PUBLISH_FAILED(20004, "Workflow version publish result failed"),
    WORKFLOW_VERSION_GET_MAX_FAILED(20005, "Failed to query workflow maximum version number, please try again later."),
    WORKFLOW_DLS_UPLOAD_FAILED(20006, "Your uploaded DSL file is incorrect, please retry"),
    WORKFLOW_TEMPLATE_NOT_EXIST(20007, "Template workflow does not exist!"),
    WORKFLOW_HIGH_PARAM_FAILED(20008, "Advanced configuration parameter replacement failed"),
    WORKFLOW_PROTOCOL_NODE_INFO_CANNOT_EMPTY(20009, "Protocol node information cannot be empty"),
    WORKFLOW_PROTOCOL_LENGTH_LIMIT(20010, "Protocol data length exceeds limit"),
    WORKFLOW_PROTOCOL_EMPTY(20011, "Flow protocol is empty"),
    WORKFLOW_NOT_EXIST(20012, "Workflow does not exist"),
    WORKFLOW_FEEDBACK_FAILED(20013, "Workflow feedback failed"),
    WORKFLOW_QUERY_LENGTH_OUTRANGE(20014, "Query input too long, supports input of no more than 30 arbitrary characters"),
    WORKFLOW_EXPORT_FAILED(20015, "Export failed"),
    WORKFLOW_VERSION_NOT_FOUND(20016, "Corresponding workflow version not found"),
    WORKFLOW_NAME_EXISTED(20017, "Workflow name is duplicated!"),
    WORKFLOW_NOT_PUBLIC(20018, "Workflow is not public, cannot be copied"),
    WORKFLOW_NOT_PUBLISH(20019, "Workflow not published"),
    WORKFLOW_IMPORT_FAILED(20020, "Import failed"),
    WORKFLOW_MCP_SERVER_REGISTRY_FAILED(20021, "MCP-Server registration failed"),

    // Tool plugin error codes
    TOOLBOX_NOT_EXIST_MODIFY(30001, "Toolbox to be modified does not exist"),
    TOOLBOX_NOT_EXIST_DELETE(30002, "Toolbox to be deleted does not exist"),
    TOOLBOX_CANNOT_DELETE_RELATED(30003, "Toolbox has associated bot usage and cannot be deleted"),
    TOOLBOX_NOT_EXIST(30004, "Tool does not exist"),
    TOOLBOX_ALREADY_COLLECT(30005, "Already collected"),
    TOOLBOX_NO_COLLECT(30006, "Tool not yet collected"),
    TOOLBOX_PARAM_TYPE_CANNOT_EMPTY(30007, "Parameter type cannot be empty"),
    TOOLBOX_PARAM_CANNOT_EMPTY(30008, "Parameter cannot be empty"),
    TOOLBOX_PARAM_AND_DESC_CANNOT_EMPTY(30009, "Parameter value and parameter description cannot be empty"),
    TOOLBOX_PARAM_GET_SOURCE_ILLEGAL(30010, "Parameter value source is illegal"),
    TOOLBOX_PARAM_TYPE_NOT_MATCH(30011, "Parameter type does not match"),
    TOOLBOX_URL_ILLEGAL(30012, "URL is illegal"),
    TOOLBOX_IP_IN_BLACKLIST(30013, "IP address is in blacklist"),
    TOOLBOX_URL_SHORT_NOT_SUPPORTED(30014, "Short URLs are not supported"),
    TOOLBOX_URL_HTTP_HTTPS_ONLY(30015, "Only http and https protocols are supported"),
    TOOLBOX_ADD_VERSION_FAILED(30016, "Plugin version addition failed"),
    TOOLBOX_CANNOT_DELETE_RELATED_WORKFLOW(30017, "Toolbox has associated workflow usage and cannot be deleted"),
    TOOLBOX_NOT_NUMBER_TYPE(30018, "Not a Number type"),
    TOOLBOX_NOT_INTEGER_TYPE(30019, "Not an Integer type"),
    TOOLBOX_NOT_BOOLEAN_TYPE(30020, "Not a Boolean type"),
    TOOLBOX_MCP_WRITE_FAILED(30021, "Failed to write MCP service data"),
    TOOLBOX_MCP_REG_FAILED(30022, "MCP registration failed"),
    TOOLBOX_NAME_EMPTY(30023, "Tool name is empty"),


    // Effect evaluation error codes
    EVALTASK_SCENE_CANNOT_EMPTY(40001, "Evaluation scene name cannot be empty"),
    EVALTASK_SCENE_NAME_EXIST(40002, "Evaluation scene name already exists"),
    EVALTASK_SCENE_NOT_EXIST(40003, "Evaluation scene does not exist"),
    EVALTASK_SCENE_CANNOT_MODIFY_OFFICIAL(40004, "Official evaluation scene cannot be modified"),
    EVALTASK_SCENE_CANNOT_DELETE_DIMENSION_EXIST(40005, "Evaluation scene has dimensions and cannot be deleted"),
    EVALTASK_SCENE_CANNOT_DELETE_OFFICIAL(40006, "Official evaluation scene cannot be deleted"),
    EVALTASK_DIMENSION_NAME_CANNOT_EMPTY(40007, "Evaluation dimension name cannot be empty"),
    EVALTASK_DIMENSION_NAME_EXIST(40008, "Evaluation dimension name already exists"),
    EVALTASK_DIMENSION_NOT_EXIST(40009, "Evaluation dimension does not exist"),
    EVALTASK_DIMENSION_CANNOT_MODIFY_OFFICIAL(40010, "Official evaluation dimension cannot be modified"),
    EVALTASK_DIMENSION_CANNOT_DELETE_OFFICIAL(40011, "Official evaluation dimension cannot be deleted"),
    EVALTASK_DIMENSION_TEMPLATE_EXPORT_FAILED(40012, "Failed to export evaluation dimension template"),
    EVALTASK_NEED_UPLOAD_FILE(40013, "Please upload file"),
    EVALTASK_XLSX_SUPPORT_ONLY(40014, "Only .xlsx format files are supported"),
    EVALTASK_STRING_LIMITED_50(40015, "Cannot exceed 50 characters"),
    EVALTASK_EXCEL_LACK_HEAD(40016, "Excel file lacks header row"),
    EVALTASK_EXCEL_LACK_ROW(40017, "Insufficient header columns"),
    EVALTASK_EXCEL_HEAD_NOT_MATCH(40018, "Column headers do not match"),
    EVALTASK_DATASET_TEMPLATE_GEN_FAILED(40019, "Failed to generate evaluation set template"),
    EVALTASK_EXCEL_NEED_HEAD_MUST(40020, "First row header should contain ['User Input (input)']"),
    EVALTASK_EXCEL_NOT_EMPTY_MUST(40021, "question, answer, sid cannot be empty (please delete hint rows in the file)"),
    EVALTASK_EXCEL_QUESTION_EMPTY(40022, "question field is empty, please check"),
    EVALTASK_BOT_NOT_EXIST(40023, "bot does not exist"),
    EVALTASK_WORKFLOW_NOT_EXIST(40024, "Workflow does not exist"),
    EVALTASK_TASK_NAME_CANNOT_EMPTY(40025, "Task name cannot be empty"),
    EVALTASK_TASM_NAME_SAME(40026, "Task name is duplicated"),
    EVALTASK_APPID_TYPE_MUST(40027, "Application ID must be a string or list"),
    EVALTASK_NO_AUTHED_MODEL(40028, "No authorized self-developed model"),
    EVALTASK_GET_AKSK_FAILED(40029, "Failed to get AKSK"),
    EVALTASK_NO_FUNCTION_CALL_INFO(40030, "No function call information found, please check if the corresponding node has function call enabled!"),
    EVALTASK_NO_YITU_INFO(40031, "No intent information obtained"),
    EVALTASK_BIANLIANG_NOT_SUPPORTED(40032, "Variable extractor node is not supported for optimization"),
    EVALTASK_NO_MARK_INFO(40033, "No annotation information found, expectedAnswer is null"),
    EVALTASK_AGENT_NOT_SUPPORTED(40034, "Agent is not supported yet"),
    EVALTASK_NO_NODE_INFO(40035, "No node information found"),
    EVALTASK_LLM_JSON_NOT_SUPPORTED(40036, "LLM node JSON answer mode is not supported yet"),
    EVALTASK_EXCEL_SECOND_HEAD_LACK(40037, "Second row header lacks input/output parameters"),
    EVALTASK_DATASET_NAME_SAME(40038, "Evaluation set name is duplicated"),
    EVALTASK_NO_WORKFLOW(40039, "Flow not found"),
    EVALTASK_WORKFLOW_PROTOCOL_EMPTY(40040, "Workflow protocol is empty"),
    EVALTASK_ID_LIST_CANNOT_EMPTY(40041, "Task ID list cannot be empty"),
    EVALTASK_NO_DATASET_REPORT(40042, "No evaluation set report"),
    EVALTASK_NO_DATASET_SID_DATA(40043, "No evaluation set node sid data"),
    EVALTASK_OFFLINE_PARAM_MISS(40044, "Missing offline evaluation parameters"),
    EVALTASK_ILLEGAL_EVAL_MODE_PARAM(40045, "Illegal evalMode parameter"),
    EVALTASK_DATASET_EMPTY_OFFLINE(40046, "Evaluation set data is empty, please select a sampling time with data for online evaluation"),
    EVALTASK_DATASET_EMPTY_ONLINE(40067, "Evaluation set data is empty, please check evaluation set content for offline evaluation"),
    EVALTASK_TASK_EXISTED(40047, "Task already exists, please do not create duplicates"),
    EVALTASK_TASK_AGAIN_FAILED(40048, "Evaluation task re-execution failed"),
    EVALTASK_DATASET_DISPLAY_FAILED(40049, "Failed to display appended evaluation data"),
    EVALTASK_TASK_STATUS_UNFINISHED(40050, "This evaluation task status is: unfinished, cannot initiate new task!"),
    EVALTASK_TASK_MODE_DOUBLE(40051, "This evaluation task is already in dual-mode evaluation, cannot initiate additional new task!"),
    EVALTASK_TASK_NEW_FAILED(40052, "Failed to initiate new task for this evaluation task"),
    EVALTASK_STATUS_QUERY_FAILED_STOP(40053, "Failed to query termination progress"),
    EVALTASK_FINE_TUNING_EXITED_IN_TASK(40054, "There is a running fine-tuning task, please stop it first before deleting"),
    EVALTASK_TASK_NOT_SUPPORT_EXCEPT_WORKFLOW(40055, "Optimization tasks other than workflow are not supported yet"),
    EVALTASK_DATASET_ID_NOT_INPUT(40056, "Training set version ID not provided"),
    EVALTASK_NODE_NOT_INPUT(40057, "Optimization node not provided"),
    EVALTASK_FT_MODEL_NOT_INPUT(40058, "Fine-tuning model ID is empty"),
    EVALTASK_DATASET_NAME_EXISTED(40059, "Evaluation task name is duplicated"),
    EVALTASK_CHECKED_DATA_EMPTY(40060, "Selected data is empty"),
    EVALTASK_NOT_QUERY_BS_INO(40061, "Unable to query baseModel information"),
    EVALTASK_AGENT_YH_TASK_NOT_SUPPORTED(40062, "Agent optimization tasks are not supported yet"),
    EVALTASK_PARSE_INPUT_PARAM_TYPE_FAILED(40063, "Failed to parse flow input parameter type"),
    EVALTASK_PAGE_SEPARATOR_MISS(40064, "Missing pagination parameters"),
    EVALTASK_EXCEL_NEED_HEAD_NUM(40065, "Header column count does not match current version column count"),
    EVALTASK_STATUS_QUERY(40068, "Failed to query task progress"),



    // Prompt engineering error codes
    PROMPT_GROUP_PROMPT_CANNOT_EMPTY(50001, "Control group protocol cannot be empty"),
    PROMPT_GROUP_SAVE_FAILED(50002, "Failed to save control group protocol"),

    // Database error codes
    DATABASE_NAME_NOT_EMPTY(60001, "Database name cannot be empty"),
    DATABASE_NAME_EXIST(60002, "Database name already exists"),
    DATABASE_CREATE_FAILED(60003, "Creation failed"),
    DATABASE_UPDATE_FAILED(60004, "Update database failed"),
    DATABASE_DELETE_FAILED_CITED(60005, "Database is referenced and cannot be deleted"),
    DATABASE_QUERY_FAILED(60006, "Failed to query database list"),
    DATABASE_NOT_EXIST(60007, "Database does not exist"),
    DATABASE_TABLE_NAME_EXIST(60008, "Table name already exists"),
    DATABASE_TABLE_FIELD_CANNOT_EMPTY(60009, "Table fields cannot be empty"),
    DATABASE_TABLE_CREATE_FAILED(60010, "Failed to create table"),
    DATABASE_ID_CANNOT_EMPTY(60011, "Database ID cannot be empty"),
    DATABASE_TABLE_QUERY_LIST_FAILED(60012, "Failed to get table list"),
    DATABASE_TABLE_QUERY_FIELD_FAILED(60013, "Failed to get table field list"),
    DATABASE_TABLE_UPDATE_FAILED(60014, "Update table failed"),
    DATABASE_TABLE_DELETE_FAILED_CITED(60015, "Table is referenced and cannot be deleted"),
    DATABASE_TABLE_DELETE_FAILED(60016, "Failed to delete table"),
    DATABASE_TABLE_OPERATION_FAILED(60017, "Table operation failed"),
    DATABASE_TABLE_FIELD_ILLEGAL(60018, "Illegal field"),
    DATABASE_TABLE_FIELD_LACK(60019, "Missing required field"),
    DATABASE_TEMPLATE_GENERATE_FAILED(60020, "Template generation failed"),
    DATABASE_TABLE_QUERY_DATA_FAILED(60021, "Failed to query table data"),
    DATABASE_IMPORT_FAILED(60022, "Data import failed"),
    DATABASE_TABLE_COPY_FAILED(60023, "Failed to copy table"),
    DATABASE_CANNOT_EMPTY(60024, "Field name, data type, description and required field cannot be empty!"),
    DATABASE_TYPE_ILLEGAL(60025, "Data type is illegal"),
    DATABASE_COPY_FAILED(60026, "Failed to copy database"),
    DATABASE_COUNT_LIMITED(60027, "Database table count has reached the limit, cannot create new tables"),
    DATABASE_FIELD_CANNOT_BEYOND_20(60028, "Table field count cannot exceed 20"),
    DATABASE_TABLE_EXPORT_FAILED(60029, "Failed to export table data"),
    DATABASE_TABLE_ILLEGAL_DEFAULT(60030, "Default value does not match field type"),
    DATABASE_TABLE_FIELD_IMPORT_DEFAULT(60031, "Import file header is not compliant"),


    // User/Group error codes
    USER_GROUP_GET_USER_INFO_FAILED(70001, "Failed to get user information"),
    USER_GROUP_TAG_CANNOT_EMPTY(70002, "Tag name cannot be empty"),
    USER_GROUP_TAG_EXIST(70003, "Tag name already exists, please do not recreate"),
    USER_NAME_CANNOT_EMPTY(70004, "User name cannot be empty"),
    USER_NOT_FOUND(70005, "Specified user not found"),
    USER_NAME_EXIST(70006, "Multiple users with the same name exist in the system, please contact platform administrator"),
    USER_CANNOT_ADD_SELF(70007, "Cannot add yourself"),
    USER_CANNOT_ADD_REPEAT(70008, "Cannot add duplicate users"),
    USER_LIST_EMPTY(70009, "User list to be saved is empty"),
    USER_TAG_RELATE_EMPTY(70010, "Tags to be associated are empty"),
    USER_UID_CANNOT_EMPTY(70011, "UID list to be removed cannot be empty"),
    USER_TAG_ID_CANNOT_EMPTY(70012, "Tag ID cannot be empty"),

    MODEL_NOT_COMPATIBLE_OPENAI(80001, "Return format not compatible with OpenAI protocol"),
    MODEL_APIKEY_ERROR(80002, "Interface address or API KEY is incorrect, please check and retry"),
    MODEL_CHECK_FAILED(80003, "Model validation failed, please check and retry"),
    MODEL_API_KEY_NOT_FOUND(80004, "Private key configuration not found"),
    MODEL_APIKEY_LOAD_ERROR(80005, "API Key loading failed"),
    MODEL_NAME_EXISTED(80006, "Model name is duplicated"),
    MODEL_NOT_EXIST(80007, "Model does not exist"),
    MODEL_GET_FINE_TUNING_FAILED(80008, "Failed to get fine-tuning model"),
    MODEL_GET_SHELF_FAILED(80009, "Failed to get shelf model"),
    PUBLIC_MODEL_GET_SHELF_FAILED(800013, "Failed to get public model"),
    MODEL_DELETE_FAILED_APPLY_AGENT(80010, "Model is used by agent and cannot be deleted"),
    MODEL_DELETE_FAILED_APPLY_WORKFLOW(80011, "Model is referenced by workflow and cannot be deleted"),
    MODEL_URL_CHECK_FAILED(80012, "URL validation failed"),
    MODEL_URL_ILLEGAL_FAILED(80012, "Illegal URL"),
    DATABASE_IMPORT_PARTIAL_FAILED(80013, "Data import failed"),


    // Common error codes
    COMMON_AUDIT_FAILED(90001, "Audit failed"),
    COMMON_EMAIL_SEND_FAILED(90002, "Email sending failed"),
    COMMON_GENERATE_PIC_FAILED(90003, "Failed to generate image"),
    COMMON_BASE_CONFIG_NOT_EXIST(90004, "Basic configuration does not exist, failed to create application"),
    COMMON_REMOTE_CALLER_FAILED(90005, "Remote call failed"),
    COMMON_NO_RECORD(90006, "No corresponding record found"),
    ;



    /**
     * Business exception code
     */
    private final Integer code;
    /**
     * Business exception message description
     */
    private final String message;

    CustomExceptionCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
